<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="Administracion de Ordenes"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form">
                <c:if test="#{commonBean.ordenesAdmon}"   >
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                <h:outputText escape="false" value="#{bundle.ListOrderOmsEmpty}" rendered="#{orderOmsController.items.rowCount == 0}"/>
                <h:panelGroup rendered="#{orderOmsController.items.rowCount > 0}">
                    <h:outputText value="#{orderOmsController.pagination.pageFirstItem + 1}..#{orderOmsController.pagination.pageLastItem + 1}/#{orderOmsController.pagination.itemsCount}"/>&nbsp;
                    <h:commandLink action="#{orderOmsController.previous}" value="#{bundle.Previous} #{orderOmsController.pagination.pageSize}" rendered="#{orderOmsController.pagination.hasPreviousPage}"/>&nbsp;
                    <h:commandLink action="#{orderOmsController.next}" value="#{bundle.Next} #{orderOmsController.pagination.pageSize}" rendered="#{orderOmsController.pagination.hasNextPage}"/>&nbsp;
                    <h:dataTable value="#{orderOmsController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Numero de Orden"/>
                            </f:facet>
                            <h:outputText value="#{item.orderid}"/>
                        </h:column>
                        
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Fecha"/>
                            </f:facet>
                            <h:outputText value="#{item.orderdate}">
                                <f:convertDateTime pattern="yyyy/MM/dd" />
                            </h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Valor"/>
                            </f:facet>
                            <h:outputText value="#{item.orderprice}"/>
                        </h:column>
                       
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Estado"/>
                            </f:facet>
                            <h:outputText value="#{item.orderstatus}"/>
                        </h:column>
                        
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Fecha de Entrega Estimada"/>
                            </f:facet>
                            <h:outputText value="#{item.estimateddelivery}">
                                <f:convertDateTime pattern="yyyy/MM/dd" />
                            </h:outputText>
                        </h:column>
                        
                       
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandLink action="#{orderOmsController.prepareView}" value="Ver Order"/>
                            <h:outputText value=" "/>
                            <h:commandLink action="#{orderOmsController.prepareEdit}" value="Editar Orden"/>
                            <h:outputText value=" "/>
                            <h:commandLink action="#{orderOmsController.destroy}" value="Eliminar Orden"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
                <br />
                <h:commandLink action="#{orderOmsController.prepareCreate}" value="Crear Orden" style="display: none;"/>
                
                </c:if>
                <c:if test="#{commonBean.ordenesAdmonConsulta}"   >
                    <br />
                    <br />
                    <h:commandLink value="Buscar Ordenes por Numero" action="OrdersByNumber" immediate="true" />
                     <br />
                    <br />
                    <h:commandLink value="Buscar Ordenes que contengan un producto dado su numero" action="OrdersByProduct" immediate="true" />
                    <br />
                    <br />
                    <h:commandLink value="Numero de Ordenes Facturadas y Total Facturado en el Mes" action="OrdersBilledByMonth" immediate="true" />
                    <br />
                    <br />
                    <h:commandLink value="Ranking de Ordenes Abiertas" action="OrdersOpen" immediate="true" />
                     <br />
                    <br />
                    <h:commandLink value="Ranking de Ordenes Cerradas que han facturado mas dinero en el mes" action="OrdersClosed" immediate="true" />
               </c:if>
                <br />
                <br />
                <h:commandLink value="Ir al Menu Principal" action="/index" immediate="true" />
            </h:form>
        </ui:define>
    </ui:composition>

</html>
